<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no">
		<title>数组扩展</title>
		<script type="text/javascript">
			//find()函数，遍历数组获得符合条件的第一个元素
			let arr = [1,2,5,-10,0,-20]
			let num = arr.find(function(item){
				return item<0
			})
			console.log(num)
			//findindex(),找到符合条件的第一个元素的下标，找到返回下标，没有返回-1
			let index = arr.findIndex(function(item){
				return item > 3
			})
			if(index>=0){
				console.log(arr[index])
			}
		</script>
	</head>
	<body>
		<div id="app">
			<!-- todo -->
		</div>
	</body>
</html>
